"""
    Author: Bai Yinna
    Date: 2024/4/22
"""

import xlrd
import os
import ast

path = os.path.dirname(os.path.abspath(__file__))
CASE_PATH = os.path.join(path , 'case.xls')
URL = 'http://20.20.1.108:8099'
HEADERS = {"Content-Type":"application/json;charset=UTF-8"}
HOSTIMPALA = '20.20.10.13'
HOSTMYSQL = ''

def getdata(index):
    # 从上述EXCEL地址中读取测试数据
    try:
        file = xlrd.open_workbook(CASE_PATH)  # 获取文档
        sheet = file.sheets()[index]  # 获取sheet
        max_rows = sheet.nrows  # 获取最大行号
        # print(max_rows)
        datalist = []
        for i in range(1, max_rows):
            test_params = {'case_number': sheet.cell(i, 0).value}  # 新建参数id并从excel取值赋值
            test_params.update({'description':sheet.cell(i, 1).value})  # 追加第二列参数如字典
            test_params.update({'is_token':sheet.cell(i, 2).value})  # 追加第三列参数如字典
            test_params.update({'index':ast.literal_eval(sheet.cell(i, 3).value)})  # 追加第三列参数如字典
            test_params.update({'meth':sheet.cell(i, 4).value})  # 追加第三列参数如字典
            test_params.update({'params':sheet.cell(i, 5).value})  # 追加第三列参数如字典
            test_params.update({'is_skip':sheet.cell(i, 6).value})  # 追加第三列参数如字典
            test_params.update({'result':sheet.cell(i, 7).value})  # 追加第三列参数如字典
            datalist.append(test_params)
            # print("datalist",datalist)
        return datalist

    except Exception as a:
        print(a)


if __name__ == '__main__':
    # getdata(0)
    print(CASE_PATH)
    # from mycore.logger import Logger1
    # Logger1().info_log("fdfdfd")
    # print(str(1))
    params = getdata(0)[0]['params']
    # from ast import literal_eval
    # params = literal_eval(params) if params else params
    print('-------------------------',params)